package com.yiyang.controller;


import com.yiyang.pojo.Bed;
import com.yiyang.pojo.Building;
import com.yiyang.pojo.vo.PageResult;
import com.yiyang.pojo.vo.Result;
import com.yiyang.service.BedService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bed")
@Tag(name = "BedController",description = "床位信息")
public class BedController {
    @Autowired
    private BedService bedService;

    @GetMapping("/{id}")
    public Result<Bed> getBedById(@PathVariable("id") Integer id){
        return bedService.getBedById(id);
    }
    @GetMapping
    public Result<PageResult<List<Bed>>> getAllBed(
            @RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "5") Integer pageSize,
            @RequestParam(name = "num",defaultValue = "") String num,
            @RequestParam(name = "brid",defaultValue = "") Integer brid
    ){
        return bedService.getAllBed(currentPage,pageSize,num,brid);
    }

    @PutMapping
    public Result<Void> addBed(@RequestBody Bed bed){
        return bedService.addBed(bed);
    }

    @PostMapping
    public Result<Void> updateBed(@RequestBody Bed bed){
        return bedService.updateBed(bed);
    }

    @DeleteMapping("/{id}")
    public Result<Void> deleteBed(@PathVariable("id") Integer id){
        return bedService.deleteBed(id);
    }
}
